<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>显示和隐藏图片</title>
</head>
<body>
    <button id="btn">隐藏</button>
    <br>
    <img src="images/1.png" id="new">
    <script>
        var obtn =document.getElementById('btn');
        var newImg =document.getElementsByTagName('img')[0];
        obtn.onclick=function(){
            if(obtn.innerHTML==='隐藏'){
                newImg.style.display= 'none';
                obtn.innerHTML ='显示';
            }else{
                newImg.style.display= 'block';
                   obtn.innerHTML = '隐藏';
            }
           
        }
    </script>
    
</body>
</html>